public void inject(final AssociationService value) throws InjectionException { providerInjector.inject(value.getLocalDiscoveryProvider()); }
@Override public void start(StartContext context) throws StartException { final AssociationService associationService = associationServiceInjectedValue.getValue(); final Endpoint endpoint = endpointValue.getValue(); Executor executor = executorService.getOptionalValue(); if (executor != null) { associationService.setExecutor(executor); } RemoteEJBService remoteEJBService = RemoteEJBService.create( associationService.getAssociation(), remotingTransactionServiceInjectedValue.getValue() ); remoteEJBService.serverUp(); // Register an EJB channel open listener OpenListener channelOpenListener = remoteEJBService.getOpenListener(); try { registration = endpoint.registerService(EJB_CHANNEL_NAME, channelOpenListener, this.channelCreationOptions); } catch (ServiceRegistrationException e) { throw new StartException(e); } }
final AssociationService associationService = new AssociationService(); final ServiceBuilder<AssociationService> associationServiceBuilder = context.getServiceTarget().addService(AssociationService.SERVICE_NAME, associationService); associationServiceBuilder.addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, associationService.getDeploymentRepositoryInjector()) .addDependency(SuspendController.SERVICE_NAME, SuspendController.class, associationService.getSuspendControllerInjector()) .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, associationService.getServerEnvironmentServiceInjector()) .setInitialMode(ServiceController.Mode.LAZY); associationServiceBuilder.addDependency(ClientMappingsRegistryServiceConfigurator.SERVICE_NAME, Registry.class, associationService.getClientMappingsRegistryInjector());
boolean editDefaultApplication(){ AssociationService serv = new AssociationService(); //try to remove old association Association logassoc = serv.getFileExtensionAssociation(".mp3"); try { serv.unregisterUserAssociation(logassoc); } catch (java.lang.IllegalArgumentException | AssociationNotRegisteredException | RegisterFailedException e) { e.printStackTrace(); return false; } //add your own application as default logassoc.addFileExtension(".mp3"); logassoc.addAction(new org.jdesktop.jdic.filetypes.Action("open", "<path to wrapper executable>")); try { serv.registerUserAssociation(logassoc); } catch (java.lang.IllegalArgumentException | AssociationNotRegisteredException | RegisterFailedException e) { e.printStackTrace(); return false; } return true; }
import org.jdesktop.jdic.filetypes.*; AssociationService serv = new AssociationService(); Association logassoc = serv.getFileExtensionAssociation("LOG"); serv.unregisterUserAssociation(logassoc);
AssociationService serv = new AssociationService(); Association logassoc = serv.getFileExtensionAssociation("LOG"); // .log ? if (logassoc == null) { return; // .log not a registered file type. }
import org.jdesktop.jdic.filetypes.*; AssociationService serv = new AssociationService(); Association logassoc = new Association(); serv.registerUserAssociation(logassoc);
AssociationService serv = new AssociationService(); Association logassoc = new Association(); logassoc.addFileExtension("DAN"); logassoc.addAction( new Action("open", "C:\\WINDOWS\\JAVA.EXE -jar C:\\dan.jar %1"));
@Override public void stop(StopContext context) { associationServiceInjectedValue.getValue().setExecutor(null); registration.close(); }
@Override public void start(StartContext context) throws StartException { EjbHttpService service = new EjbHttpService(associationServiceInjectedValue.getValue().getAssociation(), null, localTransactionContextInjectedValue.getValue()); pathHandlerInjectedValue.getValue().addPrefixPath("/ejb", service.createHttpHandler()); }
@Override public void start(StartContext context) throws StartException { final DeploymentRepository repository = deploymentRepositoryValue.getValue(); moduleIdentifier = new DeploymentModuleIdentifier(APP_NAME, MODULE_NAME, DISTINCT_NAME); final InjectedValue<ComponentView> injectedHomeView = new InjectedValue<ComponentView>(); injectedHomeView.setValue(new ImmediateValue<ComponentView>(new ManagementHomeEjbComponentView())); final InjectedValue<ComponentView> injectedRemoteView = new InjectedValue<ComponentView>(); injectedRemoteView.setValue(new ImmediateValue<ComponentView>(new ManagementRemoteEjbComponentView(mbeanServerValue.getValue()))); Map<String, InjectedValue<ComponentView>> views = new HashMap<String, InjectedValue<ComponentView>>(); views.put(ManagementHome.class.getName(), injectedHomeView); views.put(Management.class.getName(), injectedRemoteView); final EjbDeploymentInformation ejb = new ManagementEjbDeploymentInformation(EJB_NAME, views, SecurityActions.getClassLoader(this.getClass())); final ModuleDeployment deployment = new ModuleDeployment(moduleIdentifier, Collections.singletonMap(EJB_NAME, ejb)); repository.add(moduleIdentifier, deployment); repository.startDeployment(moduleIdentifier); doPrivileged((PrivilegedAction<Void>) () -> { final ClassLoader classLoader = getClass().getClassLoader(); EJBClientContext.getContextManager().setClassLoaderDefault(classLoader, ejbClientContextValue.getValue().getClientContext()); Discovery.getContextManager().setClassLoaderDefault(classLoader, Discovery.create(associationServiceInjector.getValue().getLocalDiscoveryProvider())); return null; }); }