本文整理汇总了Java中java.rmi.AlreadyBoundException类的典型用法代码示例。如果您正苦于以下问题:Java AlreadyBoundException类的具体用法?Java AlreadyBoundException怎么用?Java AlreadyBoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlreadyBoundException类属于java.rmi包,在下文中一共展示了AlreadyBoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
@Override
public void run() {
//напишите тут ваш код
try {
//создание объекта для удаленного доступа
final Animal cat = new Cat("Barsik");
final Animal dog = new Dog("Palkan");
//создание реестра расшареных объетов
registry = LocateRegistry.createRegistry(2099);
//создание "заглушки" – приемника удаленных вызовов
Remote stubCat = UnicastRemoteObject.exportObject(cat, 0);
Remote stubDog = UnicastRemoteObject.exportObject(dog, 0);
//регистрация "заглушки" в реесте
registry.bind(BINDING_NAME1, stubCat);
registry.bind(BINDING_NAME2, stubDog);
} catch (RemoteException | AlreadyBoundException e) {
e.printStackTrace();
}
}
示例2: serviceStarted
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
@Override protected void serviceStarted() {
super.serviceStarted();
String rmiServiceName = System.getProperty(PROPERTYNAME_RMISERVICENAME);
if (rmiServiceName == null) {
throw new IllegalStateException("system property '" + PROPERTYNAME_RMISERVICENAME+ "' を設定してください.");
}
try {
TefService.instance().getRmiRegistry().bind(rmiServiceName, new MplsnmsRmiServiceAccessPoint.Impl());
} catch (RemoteException re) {
throw new RuntimeException(re);
} catch (AlreadyBoundException abe) {
throw new RuntimeException(abe);
}
NaefTefService.instance().getRmcServerService()
.registerMethod(AllocateVlanIpsubnetaddr.Call.class, new AllocateVlanIpsubnetaddr.Exec());
}
示例3: main
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
public static void main(String[] args)
throws RemoteException, AlreadyBoundException {
if (args.length != 3) {
System.out.println
("args: [port] [service name]"
+ " [acceptable tef service ids (comma separated)]");
return;
}
String portStr = args[0];
String serviceName = args[1];
String[] acceptableTefServiceIds = args[2].split(",");
int port;
try {
port = Integer.parseInt(portStr);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("invalid number format: port");
}
new Impl(port, serviceName, acceptableTefServiceIds);
}
示例4: doInBackground
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
@Override
protected Object doInBackground() {
// Your Task's code here. This method runs
// on a background thread, so don't reference
// the Swing GUI from here...
String result = "stopped";
try {
if (canreg.common.ServerLauncher.start(Globals.DEFAULT_SERVER_ADDRESS, systemDescription.getSystemCode(), Globals.DEFAULT_PORT)) {
result = "started";
}
} catch (AlreadyBoundException ex) {
result = "running";
Logger.getLogger(InstallNewSystemInternalFrame.class.getName()).log(Level.INFO, null, ex);
}
// Return your result...
return result;
}
示例5: doInBackground
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
@Override
protected Object doInBackground() {
// Your Task's code here. This method runs
// on a background thread, so don't reference
// the Swing GUI from here...
String result = "stopped";
try {
if (canreg.common.ServerLauncher.start(serverURLTextField.getText(), codeField.getText(), Integer.parseInt(portField.getText()))) {
result = "started";
} else {
// if this fails, does that always mean this is running?
result = "running";
}
} catch (AlreadyBoundException ex) {
result = "running";
Logger.getLogger(LoginInternalFrame.class.getName()).log(Level.INFO, null, ex);
}
// Return your result...
return result;
}
示例6: ClusterImpl
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
public ClusterImpl(ActorSystem system, String host, String seedHost) throws RemoteException {
super();
this.system = (AbsActorSystem) system;
this.members = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
this.seed = seedHost;
if (!host.equals(seedHost))
this.uuid = host + "/" + UUID.randomUUID().toString().replaceAll("-", "");
else this.uuid = host + "/master";
try {
Naming.bind("rmi://" + this.uuid, this);
join(this.uuid);
if (!host.equals(seedHost))
updateMembers(seedHost, this.uuid);
} catch (AlreadyBoundException | MalformedURLException e) {
e.printStackTrace();
}
}
示例7: main
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
/**
* Entry point for the JVM forked by {@link #testSeparateJVMs()}.
*/
public static void main(String[] arguments) throws IOException, AlreadyBoundException, NotBoundException {
LocalController localController = new LocalController();
Registry registry = LocateRegistry.createRegistry(REGISTRY_PORT);
Controller controller = (Controller) UnicastRemoteObject.exportObject(localController, 0);
registry.bind(CONTROLLER, controller);
Path lockFile = Paths.get(arguments[0]);
RepositorySystemSession repositorySystemSession = Mockito.mock(RepositorySystemSession.class);
try (FileLockSyncContextFactory syncContextFactory = new FileLockSyncContextFactory(lockFile)) {
new SyncTask(syncContextFactory, localController, repositorySystemSession).run();
}
UnicastRemoteObject.unexportObject(localController, true);
UnicastRemoteObject.unexportObject(registry, true);
}
示例8: createNodes
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
/**
* Create several nodes on the same JVMProcess
*/
public static List<TestNode> createNodes(final String nodeName, int number)
throws IOException, NodeException, ExecutionException, InterruptedException, AlreadyBoundException {
if (number == 0) {
throw new IllegalArgumentException("" + number);
}
ArrayList<TestNode> nodes = new ArrayList<>(number);
// Start the JVMProcess and create the first node
TestNode node0 = createNode(nodeName + 0, findFreePort());
nodes.add(0, node0);
// create all subsequent nodes remotely
for (int i = 1; i < number; i++) {
Node nodei = node0.getNode().getProActiveRuntime().createLocalNode(nodeName + i, false, null);
nodes.add(new TestNode(node0.getNodeProcess(), nodei));
}
return nodes;
}
示例9: server
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
@Test
public void server() throws RemoteException, AlreadyBoundException, InterruptedException {
int port = 8030;
Registry registry = LocateRegistry.createRegistry(port);
RIImpl ro = new RIImpl();
Remote expRO = UnicastRemoteObject.exportObject(ro, port + 1);
registry.bind("ro", expRO);
registry.bind("po", (PureObj) () -> {
System.out.println("PureObj getValue");
return 1;
});
int i = 1;
while (true) {
Thread.sleep(1_000);
ro.v = i++;
}
}
示例10: bind
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
/**
* @see Registry.bind(String, Remote)
*/
public void bind(String name, Remote obj)
throws RemoteException, AlreadyBoundException, AccessException {
if (name == null) {
// rmi.5D=name could not be null.
throw new NullPointerException(Messages.getString("rmi.5D")); //$NON-NLS-1$
}
if (obj == null) {
// rmi.5C=obj could not be null.
throw new NullPointerException(Messages.getString("rmi.5C")); //$NON-NLS-1$
}
if (table.containsKey(name)) {
// rmi.5E=There is already binding to the name {0}.
throw new AlreadyBoundException(Messages.getString("rmi.5E", name)); //$NON-NLS-1$
}
checkAccess("RegistryImpl.bind"); //$NON-NLS-1$
table.put(name, obj);
}
示例11: bind
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
public void bind(XletContext xc, String path, Remote obj)
throws AlreadyBoundException {
Debug("IxcRegistry.bind(" + xc + ", " + path + ", " + obj + ")");
if (!(xc instanceof BDJXletContext) || (BDJXletContext)xc != BDJXletContext.getCurrentContext()) {
Debug("bind(): xc not current BDJXletContext");
throw new IllegalArgumentException("xc not current BDJXletContext");
}
if (((BDJXletContext)xc).isReleased()) {
Debug("bind(): xc is destroyed");
return;
}
synchronized (remoteObjects) {
if (remoteObjects.containsKey(path))
throw new AlreadyBoundException();
remoteObjects.put(path, new WrappedRemoteObj(obj, (BDJXletContext)xc));
}
}
示例12: createApplication
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
/**
* Creates an application including all the required EDMProv elements:
* agent, entity and the activity of running the app, started by the
* participant running it.
*
* @param participant the participant who runs the application
* @param name the human readable name of the application
* @param timestamp the time the application is started
* @return the application
*/
public Application createApplication(Participant participant, String name, String timestamp) {
Application app = new Application();
String appName = name.trim().substring(0, 1).toUpperCase() + name.replace(" ", "").substring(1).toLowerCase();
try {
app.activity = participant.agent.startActivity("Using" + appName + "Activity_"
+ UUID.randomUUID(), "Using " + name + " activity", timestamp);
app.entity = app.activity.generateEntity("app_entity_" + UUID.randomUUID(), name, timestamp);
app.entity.addOwlClass(provFactory.getNamespaceForPrefix("eee") + "Application");
app.agent = provFactory.createAgent("app_agent_" + UUID.randomUUID(), name);
app.agent.addTriple(provFactory.getNamespaceForPrefix("owl") + "sameAs",
app.entity.getIri(), EDMTriple.TRIPLE_TYPE.OBJECT_PROPERTY);
app.agent.actOnBehalfOf(participant.agent);
app.participant = participant;
} catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException | NoSuchFieldException e) {
logger.error("Error creating application", e);
app = null;
}
return app;
}
示例13: useDataOnClient
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
/**
* Make the participant use data on the client
*
* @param participant the participant
* @param client the application which the participant is using
* @param data the content which is used
* @param dataName the name of the data to be used for labelling
* @param timestamp the unix timestamp of this discrete useData (start=end)
* @param duration in seconds
* @return the useData of using the data
*/
public Activity useDataOnClient(Participant participant, Application client, Content data,
String dataName, String timestamp, String duration) {
Activity useData = new Activity();
try {
String dName = dataName.substring(0, 1).toUpperCase() + dataName.replaceAll(" ", "").substring(1);
if (duration == null) {
useData.activity = participant.agent.doDiscreteActivity("Use" + dName + "Activity_" + UUID.randomUUID(), "Use " + dataName, timestamp);
} else {
useData.activity = participant.agent.startActivity("Use" + dName + "Activity_" + UUID.randomUUID(), "Use " + dataName, timestamp);
participant.agent.stopActivity(useData.activity, getEndTimestamp(timestamp, duration));
}
useData.activity.useEntity(data.entity);
useData.activity.useEntity(client.entity);
} catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException e) {
logger.error("Error creating \"use data on client\" pattern", e);
}
return useData;
}
示例14: useRealWorldEntity
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
/**
* Make a participant use a real world entity
*
* @param participant the participant
* @param entity the entity to be used
* @param timestamp the unix timestamp of this discrete useData (start=end)
* @param duration in seconds
*
* @return the useData Activity of the agent using the entity
*/
public Activity useRealWorldEntity(Participant participant, Entity entity, String timestamp, String duration) {
Activity useEntity = new Activity();
try {
if (duration == null) {
useEntity.activity = participant.agent.doDiscreteActivity("UseActivity_"
+ UUID.randomUUID(), "Use " + entity.entity.getFriendlyName(), timestamp);
} else {
useEntity.activity = participant.agent.startActivity("UseActivity_"
+ UUID.randomUUID(), "Use " + entity.entity.getFriendlyName(), timestamp);
participant.agent.stopActivity(useEntity.activity, getEndTimestamp(timestamp, duration));
}
useEntity.activity.useEntity(entity.entity);
} catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException e) {
logger.error("Error creating \"use entity\" pattern", e);
}
return useEntity;
}
示例15: navigateClient
import java.rmi.AlreadyBoundException; //导入依赖的package包/类
/**
* Make the participant navigate the client
*
* @param participant the participant
* @param client the application which the participant is using
* @param timestamp the unix timestamp of this discrete activity (start=end)
* @param duration in seconds
* @return the activity of navigating
*/
public Activity navigateClient(Participant participant, Application client, String timestamp, String duration) {
Activity navigate = new Activity();
try {
if (duration == null) {
navigate.activity = participant.agent.doDiscreteActivity("NavigateClientActitivy_"
+ UUID.randomUUID(), "Navigate " + client.entity.getFriendlyName(), timestamp);
} else {
navigate.activity = participant.agent.startActivity("NavigateClientActitivy_"
+ UUID.randomUUID(), "Navigate " + client.entity.getFriendlyName(), timestamp);
participant.agent.stopActivity(navigate.activity, getEndTimestamp(timestamp, duration));
}
navigate.activity.useEntity(client.entity);
} catch (DataFormatException | DatatypeConfigurationException | AlreadyBoundException e) {
logger.error("Error creating \"navigate client\" pattern", e);
}
return navigate;
}